<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // [ ]用来匹配字符的集合
        console.log(/^[abc]$/.test("a"));//true
        console.log(/^[abc]$/.test("b"));//true
        console.log(/^[abc]$/.test("c"));//true
        console.log(/^[abc]$/.test("ab"));//false
        console.log(/^[abc]{2}$/.test("ac"));//true
        console.log("-----------------------");
        console.log(/^[a-z]$/.test("a"));//true
        console.log(/^[A-Z]$/.test("A"));//true
        console.log(/^[0-9]$/.test(1));//true
        console.log(/^[0-9a-zA-z]$/.test(1));//true
        console.log(/^[^0-9a-zA-z]$/.test(1));//false
        console.log("-----------------------");


    </script>
</body>

</html>